/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.unmsm.pacis.shca.domain.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;

/**
 *
 * @author solriver
 */
@Entity
@Table(name = "riesgo_familiar", catalog = "bdshca")
@NamedQueries({
    @NamedQuery(name = "RiesgoFamiliar.findAll", query = "SELECT r FROM RiesgoFamiliar r"),
    @NamedQuery(name = "RiesgoFamiliar.findByIdRiesgoFamiliar", query = "SELECT r FROM RiesgoFamiliar r WHERE r.idRiesgoFamiliar = :idRiesgoFamiliar"),
    @NamedQuery(name = "RiesgoFamiliar.findByRieObservacion", query = "SELECT r FROM RiesgoFamiliar r WHERE r.rieObservacion = :rieObservacion")})
public class FamilyRisk implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id_riesgo_familiar")
    private Integer id;
    @Column(name = "rie_observacion")
    private String observation;
    @JoinColumn(name = "nri_id_factor_riesgo_familiar", referencedColumnName = "id_nombre_riesgo_familiar")
    @ManyToOne(optional = false)
    private FamilyRiskName familyRiskName;
    @JoinColumn(name = "vis_id_visita_domiciliaria", referencedColumnName = "id_visita_domiciliaria")
    @ManyToOne(optional = false)
    private HomeVisit homeVisit;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "familyRisk")
    private List<RiskDate> riskDates;

    public FamilyRisk() {
    }

    public FamilyRisk(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getObservation() {
        return observation;
    }

    public void setObservation(String observation) {
        this.observation = observation;
    }

    public FamilyRiskName getFamilyRiskNamer() {
        return familyRiskName;
    }

    public void setFamilyRiskName(FamilyRiskName familyRiskName) {
        this.familyRiskName = familyRiskName;
    }

    public HomeVisit getHomeVisit() {
        return homeVisit;
    }

    public void setHomeVisit(HomeVisit homeVisit) {
        this.homeVisit = homeVisit;
    }

    public List<RiskDate> getRiskDates() {
        return riskDates;
    }

    public void setRiskDates(List<RiskDate> riskDates) {
        this.riskDates = riskDates;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof FamilyRisk)) {
            return false;
        }
        FamilyRisk other = (FamilyRisk) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pe.edu.unmsm.pacis.shca.domain.entity.FamilyRisk[ id=" + id + " ]";
    }
    
}
